package com.example.usereurekaclient.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;


@RestController
@RequestMapping("/user")
public class UserController {
    @Value("${server.port}")
    String port;


    @GetMapping("/hi")
    public String home (@RequestParam String name) throws InterruptedException {
        TimeUnit.SECONDS.sleep(1);
        System.out.println("hi");
        return "hi "+name+", i am  port :"+port;
    }


    @GetMapping("/otherhi")
    public String otherhi(@RequestParam String name) throws InterruptedException {
        TimeUnit.SECONDS.sleep(2);
        System.out.println("otherhi");
        return "otherhi"+ name +",i am port:"+port;
    }

    //ts  three second 延迟
    @GetMapping("/tshi")
    public String tshi (@RequestParam String name){
        //todo delay 3秒
        return "tshi" + name + "i am port:"+port;
    }

    @GetMapping("/goon")
    public String goon(@RequestParam String json){
        //todo delay 6秒
        return "goon";
    }


}
